package com.briup.mt.service.impl;

import com.briup.mt.bean.BaseRole;
import com.briup.mt.bean.BaseRoleExample;
import com.briup.mt.dao.BaseRoleMapper;
import com.briup.mt.service.IBaseRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author pete
 * @version 1.0
 * @date 2020/12/16 10:22
 */
@Service
public class BaseRoleServiceImpl implements IBaseRoleService {

   @Resource
   private BaseRoleMapper baseRoleMapper;

   @Override
   public List<BaseRole> query(String name){
    BaseRoleExample example = new BaseRoleExample();
       if (!StringUtils.isEmpty(name)){
           example.createCriteria().andNameLike("%" + name + "%");
       }
       return baseRoleMapper.selectByExample(example);
   }
    @Override
    public void saveOrUpdate(BaseRole baseRole) {
        if (baseRole.getId() == null) {
            baseRoleMapper.insert(baseRole);
        }else{
            baseRoleMapper.updateByPrimaryKey(baseRole);
        }
    }
    @Override
    public void deleteById(long id) {
        baseRoleMapper.deleteByPrimaryKey(id);
    }

}









